<!--
 * @Author: 高瑞寒 15932717091@163.com
 * @Date: 2022-04-25 10:33:22
 * @LastEditTime: 2022-04-25 10:59:24
 * @LastEditors: 高瑞寒 15932717091@163.com
 * @Description: 
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="test"></div>
  <script type="text/javascript" src="../js/react.development.js"></script>
  <script type="text/javascript" src="../js/react-dom.development.js"></script>
  <script type="text/javascript" src="../js/babel.min.js">
  </script>
  <script src="../js/prop-types.js"></script>
  <script type="text/babel">
    /* 
    理解:组件由开发者控制,组件的状态全程响应外部数据
    */
    class MyComponent extends React.Component {
      submit = (e) => {
        e.preventDefault();
        alert('用户名' + this.username + '密码' + this.password);
      }
      saveUsername = (e) => {
        this.username = e.target.value
      }
      savePassword = (e) => {
        this.password = e.target.value
      }
      render() {
        return (
          <form action="www.baidu.com" onSubmit={this.submit}>
            <input type="text" onChange={this.saveUsername} />
            <input type="password" onChange={this.savePassword} />
            <button>提交</button>
          </form>
        )
      }
    }
    ReactDOM.render(<div><MyComponent /></div>, document.querySelector('#test'))

  </script>
</body>

</html>